<template>
  <div v-loading="loading">
    <router-view/>
  </div>
</template>

<style lang="scss">
</style>

<script>
import { Vue, Component } from 'vue-property-decorator'
@Component
export default class App extends Vue {
  loading = true

  mounted () {
    this.loading = true
    this.$store.dispatch('area/init')
      .finally(() => {
        this.loading = false
      })
      .catch(() => {
        this.$alert('地区数据库加载失败')
      })
    window.KE.event('page-active', () => {
      if (this.$route.name !== 'login' && !this.$store.getters['auth/isLogin']) {
        console.info('未登陆')
        this.$router.push({
          name: 'login'
        })
      } else {
        console.info('检测登陆')
      }
    })
  }
}
</script>
